<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta charset="UTF-8">
		<title>宝贝编辑</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
		<meta name="description" content="Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.">
		<link rel="stylesheet" href="../lib/weui.min.css">
		<link rel="stylesheet" href="../css/jquery-weui.css">
		<link rel="stylesheet" href="../css/style.css">
	</head>
	<body ontouchstart>
		<form action="saveGoods.htm" method="post" enctype="multipart/form-data">
			<!--商品编辑开始-->
			<header class="wy-header">
				<!--返回上一页-->
				<div class="wy-header-icon-back" onclick="back();"><span></span></div>
				<div class="wy-header-title">商品编辑</div>
			</header>
			<!--商品编辑结束-->
			<!--主体-->
			<div class="wy-Module">
				<div  >
					<div class="weui-cell__bd">  <input type="file" id="chooseImage" name="path" placeholder="">
					<!-- 保存用户自定义的背景图片 -->
					<img id="cropedBigImg" style="height: 172px;width: 375px;" value='custom' alt="" data-address='' title="自定义背景"    /><input/></div>
				</div>
			</div>
			<!--主体开始-->
			<div class="weui-content" style="padding-top:10px;">
				<!--编辑宝贝信息开始-->
				<div class="weui-cells weui-cells_form wy-address-edit">
					<!--宝贝名称-->
					<div class="weui-cell">
						<div class="weui-cell__hd"><label class="weui-label wy-lab">商品名称</label></div>
						<div class="weui-cell__bd"><input class="weui-input" type="text"  placeholder="请输入商品名称；如：电脑" name="goodsName"></div>
					</div>
					<!--宝贝编码-->
					<div class="weui-cell">
						<div class="weui-cell__hd"><label class="weui-label wy-lab">商品编号</label></div>
						<div class="weui-cell__bd"><input class="weui-input" type="text"   name="goodsCode" th:value="${goodsCode}" readonly/></div>
					</div>
					<!--宝贝价格-->
					<div class="weui-cell">
						<div class="weui-cell__hd"><label class="weui-label wy-lab">商品价格</label></div>
						<div class="weui-cell__bd"><input class="weui-input" type="text" placeholder="请输入要出售的价格" required="required"  name="price" /></div>
					</div>
					<!--宝贝描述-->
					<div class="weui-cell">
						<div class="weui-cell__hd"><label class="weui-label wy-lab">商品描述</label></div>
						<div class="weui-cell__bd"><input class="weui-input" type="text" placeholder="描述你的宝贝" required="required" name="goodsDsc" /></div>
					</div>
					<!--宝贝描述-->
					<div class="weui-cell">
						<div class="weui-cell__hd"><label class="weui-label wy-lab">商品库存</label></div>
						<div class="weui-cell__bd"><input class="weui-input" type="number" placeholder="请输入输入商品的库存" required="required" pattern="[0-9]*" name="repertory"/></div>
					</div>
					<!--宝贝状态描述-->
					<div class="weui-cell">
						<div class="weui-cell__hd"><label class="weui-label wy-lab">商品状态</label></div>
						<div class="weui-cell__bd"><input class="weui-input" type="text"  value="待审核" required="required"  name="goodsState" readonly/></div>
					</div>
				</div>

				<!--宝贝保存和删除开始-->
				<div class="weui-btn-area">
					<input type="submit" class="weui-btn weui-btn_primary" id="showTooltips" value="保存编辑" />
					<!--<input type="button" class="weui-btn weui-btn_warn" value="删除宝贝" />-->
				</div>
				<!--宝贝保存和删除结束-->
			</div>
		</form>
		<!--主体结束-->
		<script src="lib/jquery-2.1.4.js"></script>
		<script src="lib/fastclick.js"></script>
		<script>
            $("#chooseImage").on("change",function(){
                var filePath = $(this).val(),         //获取到input的value，里面是文件的路径
                    fileFormat = filePath.substring(filePath.lastIndexOf(".")).toLowerCase(),
                    src = window.URL.createObjectURL(this.files[0]); //转成可以在本地预览的格式

                // 检查是否是图片
                if( !fileFormat.match(/.png|.jpg|.jpeg/) ) {
                    error_prompt_alert("上传错误,文件格式必须为：png/jpg/jpeg");
                    return;
                }

                $("#cropedBigImg").attr("src",src);
            });
			$(function() {
				FastClick.attach(document.body);
			});
            function back() {
                window.location.href=document.referrer;
            }
		</script>
		<script src="js/jquery-weui.js"></script>
		<script src="js/swiper.js"></script>
		<script src="js/jquery-1.8.3.js"></script>
	</body>

</html>